package indi.zhifa.study2025.oa.admin.controller;

import indi.zhifa.engine.core.common.web.ann.ZhiFaRestController;
import indi.zhifa.study2025.oa.admin.facade.dep.IPositionFacade;
import indi.zhifa.study2025.oa.common.util.ConstantUtil;
import indi.zhifa.study2025.oa.model.expose.dep.dto.PositionCreateDto;
import indi.zhifa.study2025.oa.model.expose.dep.dto.PositionEditDto;
import indi.zhifa.study2025.oa.model.expose.dep.vo.PositionVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Validated
@RequiredArgsConstructor
@Tag(name = "职位接口")
@ZhiFaRestController
@RequestMapping(ConstantUtil.API_PREFIX + "/positionMgr")
public class PositionController {

    final IPositionFacade mPositionFacade;

    @Operation(summary = "创建职位")
    @PostMapping
    public PositionVo create(@RequestBody PositionCreateDto pPositionCreateDto){
        return mPositionFacade.create(pPositionCreateDto);
    }

    @Operation(summary = "编辑职位")
    @PostMapping("/{id}")
    public PositionVo edit(@PathVariable("id") Long pId, @RequestBody PositionEditDto pPositionEditDto){
        return mPositionFacade.edit(pId, pPositionEditDto);
    }

    @Operation(summary = "删除职位")
    @DeleteMapping("/{id}")
    public PositionVo delete(@PathVariable("id") Long pId){
        return mPositionFacade.delete(pId);
    }

    @Operation(summary = "查看职位")
    @GetMapping("/{id}")
    public PositionVo info(@PathVariable("id") Long pId){
        return mPositionFacade.info(pId);
    }

    @Operation(summary = "查看职位列表")
    @GetMapping("/list")
    public List<PositionVo> list(){
        return mPositionFacade.list();
    }

}
